Home:ALL Converter>How do I change the text/value of "Add [Model-Name]" button in Django Admin?

How do I change the text/value of "Add [Model-Name]" button in Django Admin?

Ask Time:2022-11-22T21:54:57         Author:Khubaib Khawar

Json Formatter

When we login to Django Admin Interface as a superuser, we see the list of models on the left sidebar. When we click on any model name, we go to the list display page of that model which have 'Add [Model-Name]" button on uuper right corner. How do I change the text/value of that button? In my case, I have User Model, and I want to change the "Add User" text on list display page of User Model to "Invite User". How do I accomplish that? I have encircled the button with red in the screenshot attached.

Django Admin Interface Screenshot

I have tried different solutions told in this stackoverflow question and in this django documentation. But I am unable to achieve. I tried to override change_form.html by changing {% blocktranslate with name=opts.verbose_name %}Add {{ name }}{% endblocktranslate %} to {% blocktranslate with name=opts.verbose_name %}Invite {{ name }}{% endblocktranslate %}. I put the overriden file change_form.html in pricingmeister/accounts/templates/admin/. But i could not see the change.

The hierarchy of my Django Project and folders is below:

Django Project Hierarchy Screenshot

Below is my settings.py (truncated some code to show only relevant part of code

.
.
.
INSTALLED_APPS = [
    # Local Apps
    "pricingmeister.accounts",
    "pricingmeister.core",
    # Django Apps
    "django.contrib.admin",
    "django.contrib.auth",
    "django.contrib.contenttypes",
    "django.contrib.sessions",
    "django.contrib.messages",
    "django.contrib.staticfiles",
]
.
.
.
TEMPLATES = [
    {
        "BACKEND": "django.template.backends.django.DjangoTemplates",
        "DIRS": [],
        "APP_DIRS": True,
        "OPTIONS": {
            "context_processors": [
                "django.template.context_processors.debug",
                "django.template.context_processors.request",
                "django.contrib.auth.context_processors.auth",
                "django.contrib.messages.context_processors.messages",
            ],
        },
    },
]
.
.
.

What am I doing wrong?

Author:Khubaib Khawar,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/74533766/how-do-i-change-the-text-value-of-add-model-name-button-in-django-admin
yy